home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Utilities Professional 1-1500
/
Utilities Professional 1-1500 (1994)(WPD)[!].iso
/
12511500
/
var1308.dms
/
var1308.adf
/
DNET2_10.LHA
/
DNet
/
Amiga
/
Sourcen.lha
/
lib
/
cfg.c
next >
Wrap
C/C++ Source or Header
|
1993-01-14
|
1KB
|
76 lines
/*
* Cfg.C
*
* CONFIGURATION FILE EXTRACTION
*/
#include "lib.h"
static FILE *Fi;
int
OpenCfgFile()
{
CloseCfgFile();
Fi = fopen("s:dnet.config", "r");
return (Fi != NULL);
}
char *
GetCfgLine(what)
char *what;
{
static char Buf[128];
register char *ptr;
if (Fi) {
while (fgets(Buf, sizeof(Buf), Fi)) {
if (BCmp(Buf, what, 4) == 0) {
Buf[strlen(Buf)-1] = 0;
for (ptr = Buf + 4; *ptr == ' ' || *ptr == 9; ++ptr);
return(ptr);
}
}
}
return(NULL);
}
void
CloseCfgFile()
{
if (Fi)
fclose(Fi);
Fi = NULL;
}
void
GetOneCfg(what)
char *what;
{
char *str;
OpenCfgFile();
str = GetCfgLine(what);
CloseCfgFile();
}
int
ExtractFieldVal(str, field, pidx)
char *str, *field;
short *pidx;
{
short idx = (pidx) ? *pidx : 0;
short flen = strlen(field);
while (*str) {
if (strncmp(str, field, flen) == 0) {
if (pidx)
*pidx = idx + flen; /* past the field but not the val */
return(atoi(str + flen));
}
++str;
++idx;
}
return(-1);
}